﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AlbumList.aspx.cs" Inherits="Admin_AlbumList" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <script src="resources/jquery-1.6.2.min.js" type="text/javascript"></script>
    <link href="resources/yui-reset-min.css" rel="stylesheet" type="text/css" />
    <link href="resources/basic-control.css" rel="stylesheet" type="text/css" />
    <link href="resources/grid-view.css" rel="stylesheet" type="text/css" />
    <script src="resources/grid-view.js" type="text/javascript"></script>
    <link href="resources/edit-view.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        body
        {
            padding: 10px;
        }
    </style>
    <script type="text/javascript">
        $(function () {
            var queryFilterTitle = $('.query-filter .title');
            var queryFilterBody = $('.query-filter .body');

            queryFilterTitle.click(function () {
                queryFilterBody.toggleClass('body-hidden');
                if (queryFilterBody.hasClass('body-hidden')) {
                    queryFilterBody.slideUp('fast');
                } else {
                    queryFilterBody.slideDown('fast');
                }
            });

            queryFilterTitle.html(queryFilterTitle.html() + '<span class="tips">点击这里显示/隐藏条件筛选</span>');
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div class="edit-view query-filter">
        <div class="title">
            查询学生
        </div>
        <div class="body">
            <table>
                <tr>
                    <td width="100">
                        序号
                    </td>
                    <td>
                        <asp:TextBox ID="txtAlubmID" runat="server" ValidationGroup="Filter"></asp:TextBox>
                        <asp:RegularExpressionValidator ID="vldAlubmID" runat="server" ErrorMessage="只允许数字"
                            ControlToValidate="txtAlubmID" ValidationExpression="\d*" ValidationGroup="Filter"></asp:RegularExpressionValidator>
                    </td>
                    <td width="100">
                        发行年份
                    </td>
                    <td>
                        <asp:TextBox ID="txtPublisYear" runat="server" ValidationGroup="Filter"></asp:TextBox>
                        <asp:RegularExpressionValidator ID="vldAlubmID0" runat="server" ErrorMessage="只允许数字"
                            ControlToValidate="txtPublisYear" ValidationExpression="\d*" ValidationGroup="Filter"></asp:RegularExpressionValidator>
                    </td>
                </tr>
                <tr>
                    <td>
                        专辑名
                    </td>
                    <td>
                        <asp:TextBox ID="txtAlbumName" runat="server" ValidationGroup="Filter"></asp:TextBox>
                    </td>
                    <td>
                        歌手名
                    </td>
                    <td>
                        <asp:TextBox ID="txtSingerName" runat="server" ValidationGroup="Filter"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <asp:Button ID="btnDoQuery" runat="server" Text="查询" ValidationGroup="Filter" />
                    </td>
                    <td colspan="2" align="right">
                        &nbsp;
                    </td>
                </tr>
            </table>
        </div>
    </div>
    <asp:GridView CssClass="grid-view-default" ID="GridView1" runat="server" AutoGenerateColumns="False"
        CellPadding="0" DataKeyNames="AlbumID" DataSourceID="SqlDataSource1" GridLines="None"
        Width="100%" AllowPaging="True" PageSize="2">
        <Columns>
            <asp:TemplateField HeaderText="选择">
                <HeaderTemplate>
                    <asp:CheckBox ID="chkdAll" runat="server" />
                </HeaderTemplate>
                <ItemTemplate>
                    <asp:CheckBox ID="chkItem" runat="server" />
                </ItemTemplate>
                <HeaderStyle CssClass="check-header" />
                <ItemStyle CssClass="check-item" />
            </asp:TemplateField>
            <asp:BoundField DataField="AlbumID" HeaderText="序号" ReadOnly="True" SortExpression="AlbumID"
                InsertVisible="False" />
            <asp:BoundField DataField="AlbumName" HeaderText="专辑名" SortExpression="AlbumName" />
            <asp:BoundField DataField="Language" HeaderText="语言" SortExpression="Language" />
            <asp:BoundField DataField="SingerName" HeaderText="歌手名" SortExpression="SingerName" />
            <asp:BoundField DataField="NumberOfSongs" HeaderText="曲目数" SortExpression="NumberOfSongs" />
            <asp:TemplateField HeaderText="操作" ShowHeader="False">
                <ItemTemplate>
                    <asp:LinkButton ID="lbtnDel" OnClientClick="return confirm('确定要删除该条数据吗？');" runat="server"
                        CausesValidation="False" CommandName="Delete">
                        <asp:Image ID="imgDel" runat="server" ImageUrl="~/admin/resources/icons/109.gif" /></asp:LinkButton>
                </ItemTemplate>
                <HeaderStyle CssClass="opts-header" />
                <ItemStyle CssClass="opts-item" />
            </asp:TemplateField>
        </Columns>
        <AlternatingRowStyle CssClass="stripped" />
        <PagerStyle CssClass="pager" />
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ AppSettings:amvdb %>"
        SelectCommand="
SELECT  AlbumName, AlbumID, Language, SingerName, NumberOfSongs
FROM    Album
WHERE	(@AlbumID IS NULL OR AlbumID = @AlbumID)
AND		(@AlbumName IS NULL OR AlbumName = @AlbumName)
AND		(@SingerName IS NULL OR SingerName = @SingerName)
AND		(@PublishYear IS NULL OR PublishYear = @PublishYear)
" DeleteCommand="DELETE FROM [Album] WHERE [AlbumID] = @AlbumID" CancelSelectOnNullParameter="False">
        <DeleteParameters>
            <asp:Parameter Name="AlbumID" Type="Int32" />
        </DeleteParameters>
        <SelectParameters>
            <asp:ControlParameter ControlID="txtAlubmID" Name="AlbumID" ConvertEmptyStringToNull="true"
                PropertyName="Text" />
            <asp:ControlParameter ControlID="txtAlbumName" Name="AlbumName" ConvertEmptyStringToNull="true"
                PropertyName="Text" />
            <asp:ControlParameter ControlID="txtSingerName" Name="SingerName" ConvertEmptyStringToNull="true"
                PropertyName="Text" />
            <asp:ControlParameter ControlID="txtPublisYear" Name="PublishYear" ConvertEmptyStringToNull="true"
                PropertyName="Text" />
        </SelectParameters>
    </asp:SqlDataSource>
    </form>
</body>
</html>
